<template>
	<!-- 发起报告组件 -->
	<view class="Photo">
		<view style="position: fixed;width: 100%;background: #fff;z-index: 999;" @click="fabCloseClick">
			<uni-list>
				<uni-list-item v-if="showPropSearch" title="项目名称" showArrow clickable @click="selectXM(1)"
					:right-text="ProjectName">
					<template v-slot:footer>
						<view class="taskName">
							{{ ProjectName }}
						</view>
					</template>
				</uni-list-item>
				<uni-list-item title="任务名称" showArrow clickable @click="selectRW(1)" :right-text="TaskName">
					<template v-slot:footer>
						<view class="taskName">
							{{ TaskName }}
						</view>
					</template>
				</uni-list-item>
			</uni-list>
		</view>
		<view class="content" style="padding-top: 170rpx;" @click="fabCloseClick">
			<scroll-view scroll-y="true" @scrolltolower="lower" :style="{ height: (height - preHeight) + 'px' }">
				<view class="box" v-for="item, index in List" :key="index">
					<view class="taskName" style="line-height: 1.5;position: relative;">
						<text v-if="pid">{{ item.Name }}</text>
						<text v-else></text>
					</view>
					<view class="block" v-for="im, ix in item.TakeNotesList" :key="ix">
						<view class="left" v-if="pid">
							<view class="leftIcon">
								<image :src="im.UserIcon" mode="aspectFit"></image>
							</view>
						</view>
						<view class="right">
							<view class="rightL" @click="onClickItem(im.MediumList[0])">
								<image class="image" v-if="im.MediumList[0] && im.MediumList[0].Mtype === 'image'"
									mode="aspectFit" @click="onClickItem(im.MediumList[0])"
									:src="im.MediumList[0].Murl || ''" style="width: 100%;height: 100%;">
								</image>
								<view class="video" v-if="im.MediumList[0] && im.MediumList[0].Mtype === 'video'"
									@click="onClickItem(im.MediumList[0])">
									<image style="height: 100%; width: 53px; position: absolute;"
										:src="im.MediumList[0].Murl+'?x-oss-process=video/snapshot,t_1000,f_jpg,m_fast,ar_auto'">
									</image>
									<uni-icons type="videocam-filled" size="30" color="#ccc"
										style="z-index: 100;"></uni-icons>
								</view>
								<!-- <uni-icons class="iconBuger" size="22" type="checkbox" v-if="im.IsEnjoy"
									color="#2cd44b"></uni-icons> -->
								<image class="iconBuger" v-if="im.IsEnjoy && !pid" :src="im.UserIcon" mode="aspectFit">
								</image>
							</view>
							<view class="rightContent">
								<!-- 右侧三个点 -->
								<view class="edit" v-if="!pid">
									<view @click.stop="showPopup(im, item.Id, item.ProjectId)">
										<uni-icons type="more-filled" size="28" color="#d1100a"></uni-icons>
									</view>
									<view @click.stop="() => { }">
										<checkbox-group v-if="!im.IsEnjoy" @change="moveListChange($event, item, im)">
											<checkbox :checked="item.moveList.some(val => val.Id == im.Id)"
												:value="ix + ''" />
										</checkbox-group>
									</view>
								</view>
								<view class="blockContent">
									<view class="blockContentone" v-for="prop in im.PropData" :key="prop.ControlName">
										{{ prop.ControlName }}: {{ prop.DefaultValue }}
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<!-- <uni-load-more style="margin-top: 20rpx;" :status="List.length >= total ? 'noMore' : 'loading'" /> -->
				<view class="" style="margin-top: 100rpx;padding-bottom: 80rpx;">
					<uniLoadMore :status="status" :contentText="contentText" :rows="List"></uniLoadMore>
				</view>
				<view style="height: 40px;"></view>
			</scroll-view>
		</view>
		<view v-show="showSelect !== null" @click="showSelect = null" class="mask"> </view>

		<!-- <ImageView ref="ImageView" @TakeNotesId="getTakeNotesId" @close="imageClose"></ImageView> -->
		<!-- //阻止底层页面滚动 -->
		<view class="preview" @touchmove.stop.prevent="moveHandle">
			<ImageView ref="ImageView" @TakeNotesId="getTakeNotesId" @close="imageClose" :isEdit="isEdit"
				:isUpload="isUpload" :isSubmit="isSubmit" :parentObj="{ ...this }"></ImageView>
		</view>


		<videoView ref="videoView"></videoView>
		<listitem ref="listitem" :showAdd="false" @itemClick="XMSelect"></listitem>
		<!-- @backXM="backXM" -->
		<listitemRW ref="listitemRW" :showAdd="false" :xmId="ProjectId" :xmName="ProjectName" @itemClick="RWSelect">
		</listitemRW>
		<uni-popup ref="reportName" type="dialog">
			<uni-popup-dialog ref="inputClose" mode="input" title="报告名称" placeholder="请输入报告名称"
				:value="ProjectName + TaskName" @confirm="reportNameConfirm"></uni-popup-dialog>
		</uni-popup>
		<uni-popup ref="share" type="share" safeArea backgroundColor="#fff">
			<uni-popup-share title="操作" :bottomData="bottomData" @select="shareSelect"></uni-popup-share>
		</uni-popup>
		<uni-fab ref="fab" v-if="!pid || TaskId" :pattern="pattern" :content="fabList" horizontal="right"
			vertical="bottom" direction="horizontal" @trigger="trigger" />
		<templatePopup ref="templatePopup" @templateData="getTemplateData"
			:reportName="data.length > 0 ? data[0].ReportName || data[0].TaskName : ''" />
		<!--   -->
	</view>
</template>

<script>
	import Nav from '@/components/BackTabBar.vue'
	// import BackTabBar from '@/components/BackTabBar.vue'
	// import PopupCheckboxs from './PopupCheckboxs.vue'
	// 图片轮播预览组件
	import ImageView from '@/components/ImageViewCopy.vue'
	import videoView from '@/components/videoView.vue'
	import listitem from '@/components/listitem/listitem.vue'
	import listitemRW from '@/components/listitem/listitemRW.vue'
	import templatePopup from './template.vue'
	// 引入加载更多
	import uniLoadMore from '@/components/uni-load-more.vue'
	import {
		setStorageEntityProjectXmRwIdObj
	} from '@/utils/tools.js'
	import {
		mapActions
	} from 'vuex'
	export default {
		props: {
			showPropSearch: {
				require: false,
				default: true,
				type: Boolean
			},
			pName: {
				require: false
			},
			pid: {
				require: false
			},
			parentObj: {
				type: Object
			}
		},
		components: {
			ImageView, // 图片查看
			videoView,
			// PopupCheckboxs,
			listitem,
			listitemRW,
			Nav,
			templatePopup,
			uniLoadMore
			// BackTabBar // 返回
		},
		data() {
			return {
				// 用来判断imageViewcoyp工具栏是佛显示  显示哪些
				isUpload: true,
				isEdit: true,
				isSubmit: true,
				// 加载状态
				status: "loading",
				contentText: {
					contentdown: '',
					contentrefresh: '加载中',
					contentnomore: '没有更多了'
				},
				bottomData: [{
						icon: '/static/Btn-tu/Bian.png',
						text: '编辑',
						name: 'edit'
					}, {
						icon: '/static/Btn-tu/Gong.png',
						text: '提交',
						name: 'share'
					},
					{
						icon: '/static/Btn-tu/Shan.png',
						text: '删除',
						name: 'delete'
					},
				],
				popupData: {},
				preHeight: 0,
				showSelect: null,
				ProjectId: '', // 项目
				ProjectName: '',
				TaskId: '', // 任务
				pDFTemplateDetailesList: [], // 模板数据
				TaskName: '',
				List: [],
				data: [],
				entity: {},
				chartData0: {},
				chartData1: {},
				chartData2: {},
				chartData3: {},
				base64List: [],
				opts: {
					fontSize: 20,
					xAxis: {
						fontSize: 20,
						rotateLabel: true,
						rotateAngle: 45,
						marginTop: 20,
						format: '222',
						title: ''
					},
					yAxis: {
						data: [{
							min: 0,
							max: 100
						}]
					},
				},
				paixu: [{
						text: '按楼层排序',
						value: 'floor',
					}, {
						text: '按区域排序',
						value: 'region',
						disabled: false
					},
					{
						text: '按专业排序',
						value: 'Major',
						disabled: false
					}
				],
				ReportObj: {},
				pagination: {
					PageIndex: 1,
					PageRows: 1,
					SortField: "CreateTime",
					SortType: "desc",
				},
				imgList: [],
				total: 0,
				ControlKey: '',
				dataUrl: 'Base_ProjectWork/Base_Project/GetProjectTakeJsonData', // 默认私人数据
				pattern: {
					buttonColor: '#d1100b',
					selectedColor: '#d1100b',
					icon: 'more-filled',
					iconShow: 'more'
				},
				fabList: [{
						iconPath: '/static/fixbtn/sort1.png',
						selectedIconPath: '/static/fixbtn/sort.png',
						text: '数据排序',
						active: true
					},
					{
						iconPath: '/static/fixbtn/report1.png',
						selectedIconPath: '/static/fixbtn/report.png',
						text: '发起报告',
						active: true
					},
					// {
					// 	iconPath: '/static/fixbtn/share1.png',
					// 	selectedIconPath: '/static/fixbtn/share.png',
					// 	text: '批量提交',
					// 	active: false
					// },
					// {
					// 	iconPath: '/static/Xuan1.png',
					// 	selectedIconPath: '/static/Xuan2.png',
					// 	text: '全选',
					// 	active: false
					// }
				],
				height: 800,
				navShow: true,
				//复制   1  只有复制
				moveType: 1, //
				moveTaskId: "",
				moveProjectId: "",
				// 项目组件传递过来的当前行项目数据
				XMrow: {},
				// 任务组件传递过来的当前行任务数据
				RWrow: {},
				isClick: "", //是否点击了最上面的选择项目和任务
				// 选中好的当前或批量当前行数据id数组
				TakeNotesIds: [],
				TakeNotesListMoveList: [] //选择框选中的数组数据
			}
		},
		// 作为组件激活
		mounted() {
			// 项目所有已提交数据
			if (this.pid) {
				this.dataUrl = 'Base_ProjectWork/Base_Project/GetProjectTakeJsonData'
				this.ProjectId = this.pid
				this.ProjectName = this.pName
				this.pagination.PageRows = 10
				this.preHeight = 150
				// this.getDataList()
				this.fabList = [{
						iconPath: '/static/fixbtn/sort1.png',
						selectedIconPath: '/static/fixbtn/sort.png',
						text: '数据排序',
						active: true
					},
					{
						iconPath: '/static/fixbtn/report1.png',
						selectedIconPath: '/static/fixbtn/report.png',
						text: '发起报告',
						active: true
					},
				]
			}
			// this.getDataList()
		},
		onShow() {
			console.log('startReport,----------283')
			this.getUnreadTotal()
			this.preHeight = 0
			if (this.getNewData == true) {
				this.getNewData = false
				// this.getDataList()
				return
			}
			// 私人数据
			this.dataUrl = 'Base_ProjectWork/Base_Project/GetProjectTakeJsonData'
			// 默认未查询条件下显示一条
			// if (this.pid) this.pagination.PageRows = 10
			// else this.pagination.PageRows = 1
			// this.ProjectId = ''
			// this.ProjectName = ''
			// this.TaskId = ''
			// this.TaskName = ''
			this.pagination.PageIndex = 1
			// this.getDataList()
		},
		onLoad(options) {
			if (options.obj) {
				this.getNewData = true
				let obj = JSON.parse(options.obj)
				this.ProjectId = obj.ProjectId
				this.ProjectName = obj.pName
				this.TaskId = obj.Id
				this.TaskName = obj.Name
			}
			uni.getSystemInfo({
				success: (res) => {
					console.log(res);
					// 可使用高度减去系统状态栏高度减去自定义导航高度
					this.height = res.windowHeight - res.statusBarHeight - 44 - 92
				}
			})
		},
		onReachBottom() {
			console.log('1111');
			this.concatList()
		},
		onNavigationBarButtonTap(e) {
			console.log(e)
			uni.navigateTo({
				url: '/pages/user/user'
			})
			return true;
		},
		watch: {
			List: {
				handler(n, o) {
					if (n.length <= 0) {
						this.fabList[1].active = false
					} else {
						this.fabList[1].active = true
					}
					if (this.fabList.length > 2 && n.length > 0) {
						if (n[0].moveList.length > 0) this.fabList[2].active = true
						else this.fabList[2].active = false
						// 满足有未分享数据并且未分享数据等于已选择数据长度
						if (n[0].moveList.length == n[0].TakeNotesList.filter(item => !item.IsEnjoy).length && n[0]
							.moveList.length != 0) this.fabList[3].active = true
						else this.fabList[3].active = false
					}
				},
				deep: true
			}
		},
		methods: {
			...mapActions(['getUnreadTotal']),
			// 点击页面任意一点关闭三个点弹窗
			fabCloseClick() {
				// 默认关闭浮动按钮弹出菜单
				this.$nextTick(function() {
					this.$refs.fab.popMenu = true
					this.$refs.fab.isShow = false
				})
			},
			popMenu() {
				console.log('获取浮动fab按钮', this.$refs.fab)
				// 默认关闭浮动按钮弹出菜单
				this.$nextTick(function() {
					this.$refs.fab.popMenu = true
					this.$refs.fab.isShow = false
				})
			},
			imageClose() {
				this.navShow = true
			},
			// 参数重置
			resetParams() {
				this.ProjectId = ""
				this.TaskId = ""
				this.ControlKey = ""
			},
			shareSelect(e) {
				console.log('取消提交的浮动导航栏按钮事件了', e)
				if (e.item.name == 'edit') {
					// 判断当前移动的active是否选中  没有选中 禁止移动
					if (e.item.active == true) return uni.showToast({
						title: '已经提交禁止编辑, 请先取消提交',
						icon: 'none',
						duration: 1500
					})
					this.toEditPage(this.popupData.im, this.popupData.id, this.popupData.pid)
				}
				// else if (e.item.name == 'share'){
				// 	this.toShare(this.popupData.im, this.popupData.id, this.popupData.pid)
				// }
				else if (e.item.name == 'removeShare') { //取消提交
					this.cancelShare(this.popupData.im, this.popupData.id, this.popupData.pid)
				} else if (e.item.name === 'copy') {
					console.log('走复制')
					// let moveList =  this.List[0].moveList
					// if (moveList.length <= 0) return uni.showToast({
					// 	icon: 'none',
					// 	title: '请选择后复制'
					// // })
					// this.moveTaskId=this.List[0].Id
					// this.moveProjectId=this.List[0].ProjectId
					this.moveType = 1 //复制
					// 打开项目弹窗
					this.selectXM()

				} else if (e.item.name == 'move') {
					// 判断当前移动的active是否选中  没有选中 禁止移动
					if (e.item.active == true) return uni.showToast({
						title: '已经提交禁止移动, 请先取消提交',
						icon: 'none',
						duration: 1500
					})
				} else {
					// 判断当前移动的active是否选中  没有选中 禁止移动
					if (e.item.active == true) return uni.showToast({
						title: '已经提交禁止删除，请先取消提交',
						icon: 'none',
						duration: 1500
					})
					this.deleteTask(this.popupData)
				}
			},
			// 选择模版
			selectTemplateChange() {
				this.$refs.templatePopup.open(this.data[0].ProjectId)
			},
			complete(e) {
				// console.log(e);
			},
			getTemplateData(arr) {
				// console.log(arr);
				this.pDFTemplateDetailesList = arr
				this.dialogInputConfirm()
			},
			start(e) {
				console.log(e);
				this.base64List = e
			},
			// 删除任务
			deleteTask(data) {
				console.log('删除任务', data, this.ProjectId, this.TaskId)
				uni.showModal({
					title: '提示',
					content: '此操作将删除该任务,确认继续吗?',
					success: (val) => {
						if (val.cancel) return
						uni.showLoading()
						this.$http('Base_ProjectWork/Base_Project/DeleteUserTakeJson', {
							// 项目id
							"ProjectId": this.ProjectId,
							// 当前任务id
							"TaskId": this.TaskId,
							// 当前记录id
							"TakeNotesId": data.im.Id,
						}).then(res => {
							uni.hideLoading()
							if (res.Success) {
								uni.showToast({
									icon: 'none',
									title: '删除成功'
								})
								// 重新获取编辑列表数据
								this.getDataList()
							} else {
								uni.hideLoading()
								uni.showToast({
									icon: 'none',
									title: res.Msg
								})
							}
						})
					}
				})
			},
			// 操作展示
			showPopup(im, id, pid) {

				this.moveTaskId = id
				this.moveProjectId = pid
				console.log('报告页面操作展示区', im, this.moveTaskId, this.moveProjectId)

				let TakeNotesIds = []
				TakeNotesIds = [im.Id]
				this.TakeNotesIds = TakeNotesIds
				console.log('报告页面操作展示区当前韩数据id', this.TakeNotesIds, im.Id, this.List[0].TakeNotesList)

				if (im.IsEnjoy) {
					this.bottomData = [{
							icon: '/static/Btn-tu/Bian-off.png',
							selectedIcon: '/static/Btn-tu/Bian-off.png',
							text: '编辑',
							name: 'edit',
							active: true
						},
						{
							icon: '/static/fixbtn/share-on.png',
							selectedIcon: '/static/fixbtn/share-on.png',
							text: '取消提交',
							name: 'removeShare',
							active: false,
						},
						{
							icon: '/static/Btn-tu/copy.png',
							selectedIcon: '/static/Btn-tu/copy.png',
							text: '复制',
							name: "copy",
							active: false
						},
						{
							icon: '/static/Btn-tu/move-off.png',
							selectedIcon: '/static/Btn-tu/move.png',
							text: '移动',
							name: 'move',
							active: true,
						},
						// 只有没有提交的条件下才允许删除
						{
							icon: '/static/Btn-tu/Shan-off.png',
							selectedIcon: '/static/Btn-tu/Shan.png',
							text: '删除',
							name: 'delete',
							active: true,
						},
					]
				} else {
					this.bottomData = [
						// {
						// 	icon: '/static/Btn-tu/Bian.png',
						// 	text: '编辑',
						// 	name: 'edit'
						// },
						// {
						// 	icon: '/static/Btn-tu/Gong.png',
						// 	text: '提交',
						// 	name: 'share'
						// },
						// // 只有没有提交的条件下才允许删除
						// {
						// 	icon: '/static/Btn-tu/Shan.png',
						// 	text: '删除',
						// 	name: 'delete'
						// },
					]
				}
				this.popupData = {
					im,
					id,
					pid
				}
				this.$refs.share.open()
			},
			lower(e) {
				console.log('1111');
				this.concatList()
			},
			clickRight() {
				uni.navigateTo({
					url: '/pages/user/user'
				})
			},
			trigger(e) {
				console.log('打印length', this.List)
				if (this.List.length <= 0) return
				// 0 数据排序   1  发起报告 2   批量提交  3  全选
				if (e.index == 0) this.toMove(this.List[0])
				else if (e.index == 1) {
					// if (this.List[0].TakeNotesList.filter(item => item.IsEnjoy).length > 0) {
					// 	// uni.navigateTo({
					// 	// 	url: '/pages/report/reportView?data=' + newID
					// 	// })
					// }	else uni.showToast({
					// 	icon: 'none',
					// 	title: '无已提交数据进行发起报告'
					// })
					if (this.List[0].TakeNotesList.length <= 0) {
						uni.showToast({
							icon: 'none',
							title: '无已提交数据进行发起报告'
						})
					} else {
						this.toReport(this.List[0])
					}

					//暂时不要删除 后续待更改 目前解决方案是先跳转到详情，进行选择模版后 再发生成报告    
					// return  
					// if (this.List[0].TakeNotesList.filter(item => item.IsEnjoy).length > 0) this.toReport(this.List[0])
					// else uni.showToast({
					// 	icon: 'none',
					// 	title: '无已提交数据进行发起报告'
					// })
				} else if (e.index == 2) this.toShare(this.List[0].moveList, this.List[0].Id, this.List[0].ProjectId)
				else if (e.index == 3) {
					// 全选
					if (!e.item.active) {
						let arr = this.List[0].TakeNotesList
						let newArr = arr.filter(item => !item.IsEnjoy)
						if (newArr.length > 0) this.List[0].moveList = newArr
					} else this.List[0].moveList = []
				}
			},
			reportNameConfirm(e) {
				console.log('输入的', this.ProjectName, this.TaskName, e)
				if (!e) return uni.showToast({
					icon: 'none',
					title: '请输入报告名称'
				})

				this.ReportObj = JSON.parse(JSON.stringify(this.List[0]))
				this.ReportObj.Describe = ''
				this.ReportObj.Edition = ''
				this.ReportObj.TaskId = this.ReportObj.Id
				let ReportName = this.ProjectName + this.TaskName
				this.ReportObj.ReportName = e
				this.ReportObj.TakeNotesList = this.ReportObj.TakeNotesList.filter(item => item.IsEnjoy)
				this.$http('Base_ProjectWork/Base_Project/SaveReportData', this.ReportObj).then(resJSON => {
					uni.hideLoading()
					if (resJSON.Success) {
						this.data = resJSON.Data.reportJson
						console.log('获取赋值data', this.data, resJSON.Data.reportJson)
						let previewData = {}
						this.ids = [resJSON.Data.reportJson._id]
						this.imgList = resJSON.Data.ImgTakeNoteList
						previewData.list = this.imgList
						previewData.data = this.data
						let arr = []
						resJSON.Data.echartsValueDTOs.forEach((item, index) => {
							let titleName = index == 0 ? '区域' : index == 1 ? '专业' : index == 2 ? '问题' :
								''
							this['chartData' + index] = {
								categories: item.xAxisData,
								series: [{
									data: item.seriesData,
									name: titleName
								}],
							}
							arr.push(this['chartData' + index])
						})
						previewData.echarts = arr
						uni.setStorageSync('previewData', previewData)
						uni.navigateTo({
							url: '/pages/report/reportView?DATA=' + encodeURIComponent(JSON.stringify(this
								.ReportObj)) + '&ReportName=' + e
						})


					} else {
						uni.hideLoading()
						uni.showToast({
							icon: 'none',
							title: resJSON.Msg
						})
					}
				})
			},
			// 发起报告文件
			toReport(item) {
				console.log('打印item', item, this.ProjectName, this.TaskName)
				this.ReportObj.ReportName = this.ProjectName + this.TaskName
				this.showSelect = null
				this.$refs.reportName.open()

				return
				uni.showModal({
					title: '提示',
					content: '此操作将以当前排序发起报告,确认继续吗?',
					success: (val) => {
						if (val.cancel) return
						this.ReportObj = JSON.parse(JSON.stringify(item))
						this.$refs.reportName.open()

					},
				})
				// uni.showLoading({
				// 	title: '正在打开报告模板',
				// 	mask: true
				// })

				this.ReportObj = JSON.parse(JSON.stringify(item))
				this.ReportObj.Describe = ''
				this.ReportObj.Edition = ''
				this.ReportObj.TaskId = this.ReportObj.Id
				this.ReportObj.ReportName = this.ProjectName + this.TaskName
				this.ReportObj.TakeNotesList = this.ReportObj.TakeNotesList.filter(item => item.IsEnjoy)
				let newID = ""
				if (typeof this.parentObj.data[0]._id == 'string') {
					newID = JSON.stringify([this.parentObj.data[0]._id])
				} else {
					newID = JSON.stringify(this.parentObj.data[0]._id)
				}
				console.log('打印id---', this.parentObj.data[0]._id, newID)
				// uni.showLoading()
				this.$http('Base_ProjectWork/Base_Project/SaveReportData', this.ReportObj).then(resJSON => {
					uni.hideLoading()
					if (resJSON.Success) {
						this.data = resJSON.Data.reportJson
						console.log('获取赋值data', this.data, resJSON.Data.reportJson)
						let previewData = {}
						this.ids = [resJSON.Data.reportJson._id]
						this.imgList = resJSON.Data.ImgTakeNoteList
						previewData.list = this.imgList
						previewData.data = this.data
						let arr = []
						resJSON.Data.echartsValueDTOs.forEach((item, index) => {
							let titleName = index == 0 ? '区域' : index == 1 ? '专业' : index == 2 ? '问题' :
								''
							this['chartData' + index] = {
								categories: item.xAxisData,
								series: [{
									data: item.seriesData,
									name: titleName
								}],
							}
							arr.push(this['chartData' + index])
						})
						previewData.echarts = arr
						uni.setStorageSync('previewData', previewData)

						console.log('获取整体数据', resJSON.Data, this.ids, this.data, this.imgList, previewData, this
							.ReportObj)

						uni.navigateTo({
							url: '/pages/report/reportView?DATA=' + JSON.stringify(this.ReportObj)
						})


					} else {
						uni.hideLoading()
						uni.showToast({
							icon: 'none',
							title: res.Msg
						})
					}
				})

			},
			getTemplateData(arr) {
				// console.log(arr);
				this.pDFTemplateDetailesList = arr
				this.dialogInputConfirm()
			},
			dialogInputConfirm(e) {
				// if (this.data[0].PdfUrl) {
				// 	this.showModal(this.data[0].PdfUrl)
				// } else {
				uni.showLoading({
					title: 'PDF生成中',
					mask: true
				})
				console.log(this.base64List, 'echarts642')
				this.$http('Base_ProjectWork/Base_Project/GetReportPDF', {
					"Ids": this.ids,
					"ProjectSchedule": "",
					"EchartsImg": this.base64List,
					pDFTemplateDetailesList: this.pDFTemplateDetailesList
				}).then(res => {
					console.log(res);
					uni.hideLoading()
					if (res.Success) {
						this.showModal(res.Data)
					} else {
						uni.hideLoading()
						uni.showToast({
							icon: 'none',
							title: res.Msg
						})
					}
				})
				// }
			},
			moveHandle() {},
			// 弹窗提示
			showModal(url) {
				console.log(url);
				uni.showModal({
					title: '提示',
					content: `PDF已生成,请选择下载或分享\n注:获得编辑版本请登录zytsaas.com`,
					cancelText: '分享',
					confirmText: '下载',
					success: (val) => {
						if (val.confirm) {
							this.download(url)
						} else {
							this.share(url)
						}
					}
				})
			},
			// 下载
			download(url) {
				uni.showLoading({
					title: 'PDF下载中',
					mask: true
				})
				uni.downloadFile({
					url,
					header: {
						'Access-Control-Allow-Origin': '*'
					},
					filePath: '/Download',
					success: (res) => {
						console.log(res);
						uni.openDocument({
							filePath: res.tempFilePath,
							success: function(res) {
								console.log('打开文档成功');
							},
							fail: function(res) {
								uni.showToast({
									title: JSON.stringify(res)
								})
							}
						})
					},
					fail: (err) => {
						uni.showToast({
							icon: 'none',
							title: 'PDF下载失败,请重新尝试'
						})
					},
					complete() {
						uni.hideLoading()
					}
				})
			},
			// 微信分享
			share(url) {
				uni.share({
					provider: "weixin",
					scene: "WXSceneSession",
					type: 0,
					href: url, // 分享跳转的链接
					title: "报告分享", // 分享标题
					summary: this.data[0].ProjectName + "报告", // 分享内容文字
					imageUrl: "https://www.yoojet.com/wx.png", //分享封面图片
					success: function(res) {
						// 此处是调起微信分享成功的回调
					},
					fail: function(err) {
						// 此处是调起微信分享失败的回调
						console.log(err);
					}
				});
			},
			// 图片页面传递数据
			getTakeNotesId(obj) {
				console.log(obj);
				let parentObj = this.List.find(item => item.ProjectId == obj.ProjectId && item.Id == obj.TaskId)
				let sonObj = parentObj.TakeNotesList.find(item => item.Id == obj.TakeNotesId)
				if (sonObj.IsEnjoy) return this.$refs.ImageView.showTips('当前数据已完成提交')
				uni.showLoading()
				this.$http('Base_ProjectWork/Base_Project/EnjoyTogetherProject', {
					...obj
				}).then(res => {
					uni.hideLoading()
					if (res.Success) {
						this.$refs.ImageView.showTips('提交成功')
						sonObj.IsEnjoy = true
					} else {
						uni.hideLoading()
						this.$refs.ImageView.showTips(res.Msg)
					}
				})

			},
			// 排序
			changeSelect(e) {
				console.log(e);
				this.ControlKey = e
				this.getDataList()
			},
			// 查看详情
			toDetail(im) {
				uni.navigateTo({
					url: '/pages/Inspection/Detail?data=' + JSON.stringify(im)
				})
			},

			// 走复制和移动逻辑了
			moveTypeRequest() {
				console.log('报告页面走复制逻辑了', this.moveType, this.moveTaskId, this.moveProjectId, this.TakeNotesIds, this
					.moveType,
					this.XMrow, this.RWrow)
				let obj = {
					FromProjectId: this.moveProjectId, //从当前的项目
					FromTaskId: this.moveTaskId, //从当前的任务
					ToProjectId: this.XMrow.ProjectId, //复制或移动到的项目
					ToTaskId: this.RWrow.Id, //复制或移动到的任务
					TakeNotesIds: this.TakeNotesIds, //巡检记录id数组
					OperateType: 1, //编辑菜单 0   报告菜单1
					MoveType: 1 //复制
				}
				console.log('最终传递的参数', obj)
				uni.showLoading({
					title: '复制中'
				})
				// 判断如果是复制或移动 更新缓存对象
				// 更新缓存EntityProjectXmRwIdObj对象
				let EntityProjectXmRwIdObj = {
					xmId: this.XMrow.ProjectId,
					rwId: this.RWrow.Id,
					xmName: this.XMrow.Name,
					rwName: this.RWrow.Name,
				}
				this.ProjectId = this.XMrow.ProjectId
				this.TaskId = this.RWrow.Id
				setStorageEntityProjectXmRwIdObj(EntityProjectXmRwIdObj)

				this.$http("Base_ProjectWork/Base_Project/MoveData", obj).then(res => {
					uni.hideLoading()
					if (res.Success) {
						uni.hideLoading()
						setTimeout(function() {
							uni.showToast({
								title: '操作成功',
							})
						}, 200)
						// 刷新列表
						this.getDataList()

					} else {
						uni.hideLoading()
						uni.showToast({
							icon: 'none',
							title: res.Msg
						})
					}
				})
			},
			// 选择项目
			selectRW(data) {
				this.isClick = data
				if (!this.ProjectId) return uni.showToast({
					icon: 'none',
					title: '请选择项目'
				})
				this.$refs.listitemRW.open()
			},
			XMSelect(row) {
				this.XMrow = row

				console.log('报告页面传递过来的项目列表数据', row, this.ProjectId, this.ProjectName)
				if (this.isClick == 1) { // 说明点击了最上面的选择项目和任务
					this.moveType = 1 //初始化
					// 项目id赋值
					this.ProjectId = row.ProjectId
					// 项目名称赋值
					this.ProjectName = row.ProjectName || row.Name
					this.TaskId = ''
					this.TaskName = ''
					this.List = []
					if (this.fabList.length > 2) this.fabList[2].active = false
					// 切换至默认查询条件下显示一条
					if (this.pid) this.pagination.PageRows = 10
					else this.pagination.PageRows = 1

				} else {
					this.isClick = "" //初始化
					// 项目id赋值
					this.ProjectId = row.ProjectId
					// 项目名称赋值
					// this.ProjectName = row.Name
					// 判断是否操作了复制和移动
					if (this.moveType == 1) {
						// 说明操作了复制  弹出项目和任务弹窗
						this.$refs.listitemRW.open()

						return
					}
				}

				console.log('报告页面打印是否点击了复制开始弹出任务了', this.moveType)
			},
			// 选择项目
			selectXM(data) {
				console.log('报告页面是否点击了最上面', data)
				this.isClick = data
				this.$refs.listitem.open()
			},
			RWSelect(row) {
				this.RWrow = row
				console.log('传递过来的任务列表数据', row, this.ProjectId, this.ProjectName, this.TaskId, this.TaskName, this.fabList)
				if (this.isClick == 1) { //点击的是最上面的选择项目 选择任务 
					this.moveType = 1
					if (this.fabList.length > 2) this.fabList[2].active = false
					this.TaskId = row.Id
					this.TaskName = row.Name
					this.getDataList()
					console.log(row)
				} else {
					this.isClick = 1 //初始化
					// 判断是否操作了复制
					if (this.moveType == 1) {
						// 说明操作了复制   走复制和移动逻辑
						this.moveTypeRequest()
						return
					}
				}
				// if (this.fabList.length > 2) this.fabList[2].active = false
				// this.TaskId = row.Id
				// this.TaskName = row.Name
				// this.getDataList()
				// console.log(row)
			},
			concatList() {
				console.log('触发');
				if (this.List.length >= this.total) {
					this.status = "noMore"
					return
				}
				this.pagination.PageIndex++
				this.$http(this.dataUrl, {
					...this.pagination,
					"Search": {
						"ProjectId": this.ProjectId,
						TaskId: this.TaskId,
						ControlKey: this.ControlKey,
					}
				}).then(res => {
					if (res.Success) {
						this.List = this.List.concat(res.Data.map(item => {
							item.moveList = []
							return item
						}))
						this.total = res.Total
						if (this.List.length >= this.total) {
							this.status = "noMore"
							return
						}
					} else {
						this.status = "noMore"
						uni.showToast({
							icon: 'none',
							title: res.Msg
						})
					}
				})
			},
			// 去移动页面
			toMove(list) {
				// if (list.length <= 0) return uni.showToast({
				// 	icon: 'none',
				// 	title: '请选择数据'
				// })
				let ReportType = this.pid ? 1 : 0
				uni.setStorageSync('moveList', list)
				uni.navigateTo({
					url: '/pages/MovePage/MovePage?ReportType=' + ReportType + '&report=1'
				})
			},
			// 选中去移动页面数据
			moveListChange(e, item, im) {
				console.log(e.detail.value[0], item, im);
				if (e.detail.value[0] !== undefined) {
					item.moveList.push(im)
				} else {
					let idx = item.moveList.findIndex(val => val.Id == im.Id)
					item.moveList.splice(idx, 1)
				}
			},
			// 取消提交
			cancelShare(item, id, pid) {
				this.showSelect = null
				uni.showModal({
					title: '提示',
					content: '此操作将取消本条数据提交状态,确认继续吗?',
					success: (val) => {
						if (val.cancel) return
						// 更新缓存EntityProjectXmRwIdObj对象
						let obj = {
							xmId: this.List[0].ProjectId,
							rwId: this.List[0].Id,
							xmName: this.List[0].ProjectName,
							rwName: this.List[0].Name,
						}
						setStorageEntityProjectXmRwIdObj(obj)

						uni.showLoading()
						this.$http('Base_ProjectWork/Base_Project/CancelEnjoyTogetherProject', {
							TakeNotesId: item.Id,
							ProjectId: pid,
							TaskId: id,
							TakeNotesList: []
						}).then(res => {
							uni.hideLoading()
							if (res.Success) {
								uni.showToast({
									icon: 'none',
									title: '操作成功'
								})
								item.IsEnjoy = false
								// 刷新当前报告列表
								this.pagination.PageIndex = 1
								this.getDataList()
							} else {
								uni.hideLoading()
								uni.showToast({
									icon: 'none',
									title: res.Msg
								})
							}
						})
					}
				})
			},
			// 提交
			toShare(item, id, pid) {
				this.showSelect = null
				let TakeNotesList = []
				if (!Array.isArray(item)) {
					let obj = JSON.parse(JSON.stringify(item))
					obj.IsEnjoy = true
					TakeNotesList = [{
						...obj
					}]
				} else {
					if (item.length <= 0) return uni.showToast({
						icon: 'none',
						title: '请选择后提交'
					})
					let arr = JSON.parse(JSON.stringify(item))
					arr.forEach(item => item.IsEnjoy = true)
					TakeNotesList = arr
				}

				uni.showModal({
					title: '提示',
					content: '此操作将对本条数据进行提交,确认继续吗?',
					success: (val) => {
						if (val.cancel) return
						uni.showLoading()
						this.$http('Base_ProjectWork/Base_Project/EnjoyTogetherProject', {
							...item,
							ProjectId: pid,
							TaskId: id,
							TakeNotesList
						}).then(res => {
							uni.hideLoading()
							if (res.Success) {
								uni.showToast({
									icon: 'none',
									title: '提交成功'
								})
								if (!Array.isArray(item)) item.IsEnjoy = true
								else item.forEach(item => item.IsEnjoy = true)
							} else {
								uni.hideLoading()
								uni.showToast({
									icon: 'none',
									title: res.Msg
								})
							}
						})
					}
				})
			},
			// 修改
			toEditPage(item, id, pid) {
				this.showSelect = null
				uni.navigateTo({
					url: `/pages/EditPage/EditPage?data=${JSON.stringify(item)}&type=2&id=${id}&pid=${pid}&interface=1`
				})
			},
			subclickRow(row) {
				console.log(row)
			},
			onClick(event, ownerInstance) {
				let this_ = this;
				console.log(123)
				// 调用 service 层的方法
				setTimeout(function() {
					const loadCanvas0 = document.getElementById('chart0'); //将canvas转换成beast64 
					const base64Str0 = loadCanvas0.firstChild.toDataURL('image/jpg');
					const loadCanvas1 = document.getElementById('chart1'); //将canvas转换成beast64 
					const base64Str1 = loadCanvas1.firstChild.toDataURL('image/jpg');
					const loadCanvas2 = document.getElementById('chart2'); //将canvas转换成beast64 
					const base64Str2 = loadCanvas2.firstChild.toDataURL('image/jpg');
					this_.start([base64Str0, base64Str1, base64Str2])
				}, 400);
			},
			onClickItem(img) {
				console.log('获取点击的图片------------------------img, this.imgList, ', this.parentObj)
				let idx = this.imgList.findIndex(item => item.Murl == img.Murl)
				this.navShow = false
				let obj = {
					imgList: this.imgList,
					idx: idx == -1 ? 0 : idx,
					noEdit: true
				}
				this.$refs.ImageView.open(this.imgList, idx == -1 ? 0 : idx)
			},
			getDataList() {
				// 检查网络设置，，是否存在网络   设置加载提示  避免后续再没有网络条件下，，接口频繁请求  导致  一直存在正在加载的提示框的问题  只有有网络的情况下去加载
				uni.getNetworkType({
					success: (res) => {
						console.log('获取网络状态', res)
						if (res.networkType === "none") {
							console.log("当前无网络");
							this.status = "noMore"
							uni.showToast({
								title: '当前网络信号异常',
								icon: "none"
							});
						} else {
							console.log("有网络");
							this.status = "loading"

						}
					}
				})
				this.List = []
				this.pagination.PageIndex = 1

				this.$http(this.dataUrl, {
					...this.pagination,
					"Search": {
						"ProjectId": this.ProjectId,
						TaskId: this.TaskId,
						ControlKey: this.ControlKey
					}
				}).then(res => {
					uni.hideLoading()
					if (res.Success) {
						console.log('获取报告列表res结果', res.Data)
						this.List = res.Data.map(item => {
							item.moveList = []
							if (!this.pid) {
								if (item.TakeNotesList.every(im => im.UserIndexSort == 0)) {
									let userId = uni.getStorageSync('userInfo').Id
									let arr1 = item.TakeNotesList.filter(item => item.CreatorId == userId)
									let arr2 = item.TakeNotesList.filter(item => item.CreatorId != userId)
									item.TakeNotesList = arr1.concat(arr2)
								} else {
									item.TakeNotesList = item.TakeNotesList.sort((a, b) => a
										.UserIndexSort - b.UserIndexSort)
								}
							}
							return item
						})
						console.log('获取最终赋值后的报告列表', this.List)
						// 自动获取上方项目名称任务名称
						if (!this.pid && this.List.length == 1) {
							this.ProjectId = this.List[0].ProjectId
							this.ProjectName = this.List[0].ProjectName
							this.TaskId = this.List[0].Id
							this.TaskName = this.List[0].Name
						}
						this.imgList = res.ListDetail
						if (this.List.length >= this.total) {
							this.status = "noMore"
							return
						}
					} else {
						this.status = "noMore"
						this.List = []
						this.imgList = []
						uni.showToast({
							icon: 'none',
							title: res.Msg
						})
					}
				})
			}
		}
	}
</script>
<style scoped lang="scss">
	/deep/.uni-checkbox-input {
		margin-right: 0;
	}

	/deep/.uni-list-item__container {
		align-items: center;
		padding: 5px;
		padding-left: 15px;
		height: 46px;
	}

	.color {
		color: #d1100a !important;
	}

	.mask {
		position: fixed;
		width: 100vw;
		height: 100vh;
		background-color: transparent;
		top: 0;
		left: 0;
	}

	.centerflex {
		display: flex;
		align-items: center;
	}

	.projectInfo {
		padding: 0 20rpx;

		.project {
			font-size: 34rpx;
			margin-bottom: 20rpx;
			color: #000;
		}

		.application {
			color: #999;
		}
	}

	.margin {
		margin: 0 2%;
	}

	.taskName {
		padding: 0 15rpx;
		font-size: 36rpx;
		color: #336dba;
		font-weight: 600;
		line-height: 2;
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 480rpx;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.content {
		// margin-top: 20rpx;
		// padding-bottom: 50px;

		.select {
			position: absolute;
			border: 1px solid #dedede;
			top: 15px;
			right: 0;
			padding: 10rpx 0;
			text-align: center;
			background-color: #fff;
			border-radius: 10rpx;
			width: 150rpx;
			box-shadow: 2px 5px 5px 0 rgba(0, 0, 0, .3);
			z-index: 10;
			font-size: 15px;
			color: #000;
			font-weight: normal;

			.selectItem {
				padding: 20rpx 0;

				&:active {
					background-color: #f5f5f5;
				}
			}
		}

		.box {
			border-bottom: 1px solid #ededed;
		}


		.block {
			display: flex !important;
			border-top: 1px solid #ededed;
			padding: 10rpx 0;
			align-items: center;

			.left {
				width: 100rpx;
				overflow: hidden;
				padding-left: 15rpx;
				text-align: center;

				.leftIcon {
					width: 70rpx;
					height: 70rpx;
					border-radius: 50%;
					overflow: hidden;

					image {
						width: 100%;
						height: 100%;
					}
				}

			}

			.right {
				flex: 1;
				box-sizing: border-box;
				padding: 0 15rpx;
				display: flex;

				.rightL {
					width: 65px;
					height: 65px;
					border: 1px solid #dfdfdf;
					border-radius: 10rpx;
					margin-right: 10px;
					position: relative;
					padding: 10rpx;

					.image {
						width: 100%;
						height: 100%;
					}

					.video {
						width: 100%;
						height: 100%;
						background: #fff;
						position: relative;
						display: flex;
						justify-content: center;
						align-items: center;
					}

					.iconBuger {
						position: absolute;
						right: 0;
						top: 0;
						font-weight: bold;
						width: 22px;
						height: 22px;
						border-radius: 50%;
					}
				}

				.rightContent {
					flex: 1;
					position: relative;
					width: 100px;

					.edit {
						height: 100%;
						display: flex;
						align-items: center;
						position: relative;
						flex-direction: column;
						justify-content: space-between;
						position: absolute;
						right: 10px;
						top: 0;

						.icon {
							margin: 0 20rpx;
						}
					}
				}

				.blockContent {
					width: calc(100% - 40px);
					display: flex;
					height: 100%;
					align-items: center;
					flex-wrap: wrap;

					.blockContentone {
						width: 50%;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}

				.picBox {
					display: flex;
					flex-wrap: wrap;
					margin: 20rpx 0;

					.pic {
						height: 210rpx;
						box-sizing: border-box;
						border: 1px solid #ccc;
						width: 32%;
						margin-bottom: 10rpx;

					}

					.videoBox {
						width: 100%;
						height: 100%;
						display: flex;
						align-items: center;
						justify-content: center;
					}
				}
			}
		}
	}
</style>